


package ciicos.work.controller;

import ciicos.base.ActionResult;
import ciicos.base.UserInfo;
import ciicos.base.vo.DownloadVO;
import ciicos.base.vo.PageListVO;
import ciicos.base.vo.PaginationVO;
import ciicos.check.entity.CheckPlanItemEntity;
import ciicos.check.entity.CheckTaskAnomalyEntity;
import ciicos.check.service.CheckPlanItemService;
import ciicos.check.service.CheckTaskAnomalyService;
import ciicos.config.ConfigValueUtil;
import ciicos.exception.DataException;
import ciicos.permission.entity.UserEntity;
import ciicos.util.DateUtil;
import ciicos.util.ExcelUtil;
import ciicos.util.FileUploadUtils;
import ciicos.util.GeneraterSwapUtil;
import ciicos.util.JsonUtil;
import ciicos.util.RandomUtil;
import ciicos.util.StringUtil;
import ciicos.util.UploaderUtil;
import ciicos.util.UserProvider;
import ciicos.work.entity.WorkInfoEntity;
import ciicos.work.model.workinfo.WorkInfoForm;
import ciicos.work.model.workinfo.WorkInfoInfoVO;
import ciicos.work.model.workinfo.WorkInfoListVO;
import ciicos.work.model.workinfo.WorkInfoPagination;
import ciicos.work.service.WorkInfoService;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.xuyanwu.spring.file.storage.FileInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * 工单信息
 *
 * @版本： V3.2.0
 * @版权：
 * @作者： 产研项目租
 * @日期： 2023-08-02
 */
@Slf4j
@RestController
@Api(tags = "工单信息", value = "workManage")
@RequestMapping("/api/workManage/WorkInfo")
public class WorkInfoController {


    @Autowired
    private GeneraterSwapUtil generaterSwapUtil;


    @Autowired
    private UserProvider userProvider;


    @Autowired
    private WorkInfoService workInfoService;


    @Autowired
    private ConfigValueUtil configValueUtil;

    @Autowired
    private CheckTaskAnomalyService checkTaskAnomalyService;




    @PostMapping("/submitConfirmData")
    @Transactional
    public ActionResult submitConfirmData(@RequestBody WorkInfoForm workInfoForm) {
        WorkInfoEntity entity = JsonUtil.getJsonToBean(workInfoForm, WorkInfoEntity.class);
        // 更新结果
        WorkInfoEntity info = workInfoService.getInfo(entity.getId());
        info.setConfirmtime(new Date());
        UserInfo userInfo = userProvider.get();
        UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
        info.setConfirmuserid(userEntity.getId());
        info.setConfirmresult("不合格");
        if (!StringUtil.isEmpty(entity.getNoseason())) {
            info.setNoseason(entity.getNoseason());
        }
        workInfoService.updateById(info);


        return ActionResult.success();
    }

    /**
     * 记录确认结果
     */
    @ApiOperation("记录确认结果")
    @GetMapping("/updateConfirmRes/{id}")
    @Transactional
    public ActionResult updateConfirmRes(@PathVariable String id) {
        WorkInfoEntity info = workInfoService.getInfo(id);
        info.setConfirmtime(new Date());
        UserInfo userInfo = userProvider.get();
        UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
        info.setConfirmuserid(userEntity.getId());
        info.setConfirmresult("合格");

        workInfoService.updateById(info);
        return ActionResult.success();
    }


    /**
     * 获取列表：pc端、app有网的情况
     *
     * @param workInfoPagination
     * @return
     */
    @ApiOperation("获取列表")
    @PostMapping("/getList")
    public ActionResult list(@RequestBody WorkInfoPagination workInfoPagination) throws IOException {
        //树形判断是否有参数，有参数不造树
        List<WorkInfoEntity> list = workInfoService.getList(workInfoPagination);
        //处理id字段转名称，若无需转或者为空可删除
        List<WorkInfoListVO> listVO = JsonUtil.getJsonToList(list, WorkInfoListVO.class);
        for (WorkInfoListVO workInfoVO : listVO) {
            ActionResult info = info(workInfoVO.getId());
            Map<String, Object> dataMap = JsonUtil.entityToMap(info.getData());
            workInfoVO.setCreatoruserid_name(generaterSwapUtil.userSelectValue(workInfoVO.getCreatoruserid()));

            workInfoVO.setCreatortime_name(workInfoVO.getCreatortime());

            workInfoVO.setSource_name(generaterSwapUtil.getDicName(workInfoVO.getSource(), "532159486043887237"));
            workInfoVO.setFinishStatus_name(generaterSwapUtil.getDicName(workInfoVO.getFinishStatus(), "532187133922776773"));


            workInfoVO.setSelectteam_name(generaterSwapUtil.comSelectValues(workInfoVO.getSelectteam(), false));

            workInfoVO.setEnabledmark_name(generaterSwapUtil.switchSelectValue(workInfoVO.getEnabledmark(), "是", "否"));

            workInfoVO.setQuestion_name(workInfoVO.getQuestion());

            workInfoVO.setField04_name(workInfoVO.getField04());

            workInfoVO.setField03_name(workInfoVO.getField03());

            workInfoVO.setFiles_name(generaterSwapUtil.getFileNameInJson(workInfoVO.getFiles()));

            workInfoVO.setHandleuserid_name(generaterSwapUtil.userSelectValues(workInfoVO.getHandleuserid()));

            workInfoVO.setHandletime_name(workInfoVO.getHandletime() != null ?
                    new Date(workInfoVO.getHandletime()) : null);

            workInfoVO.setHandleresult_name(workInfoVO.getHandleresult());

            workInfoVO.setPrevent_name(workInfoVO.getPrevent());

            workInfoVO.setImages_name(generaterSwapUtil.getFileNameInJson(workInfoVO.getImages()));

            workInfoVO.setConfirmuserid_name(generaterSwapUtil.userSelectValues(workInfoVO.getConfirmuserid()));

            workInfoVO.setConfirmtime_name(workInfoVO.getConfirmtime() != null ?
                    new Date(workInfoVO.getConfirmtime()) : null);
            workInfoVO.setWorkencode_name(workInfoVO.getWorkEncode());


            //根据发现人用户id获取到用户姓名
            workInfoVO.setField02_name(generaterSwapUtil.userSelectValue(workInfoVO.getField02()));
            workInfoVO.setPds_name(workInfoVO.getPds());

            //子表数据转换
        }

        PageListVO vo = new PageListVO();
        vo.setList(listVO);
        PaginationVO page = JsonUtil.getJsonToBean(workInfoPagination, PaginationVO.class);
        vo.setPagination(page);
        return ActionResult.success(vo);

    }


    /**
     * 获取列表：app端没有网的情况
     *
     * @param workInfoPagination
     * @return
     */
    @ApiOperation("获取列表")
    @PostMapping("/getListNoNet")
    public ActionResult getListNoNet(@RequestBody WorkInfoPagination workInfoPagination) throws IOException {
        //树形判断是否有参数，有参数不造树
        List<WorkInfoEntity> list = workInfoService.getListNoNet(workInfoPagination);
        //处理id字段转名称，若无需转或者为空可删除
        List<WorkInfoListVO> listVO = JsonUtil.getJsonToList(list, WorkInfoListVO.class);
        for (WorkInfoListVO workInfoVO : listVO) {
            ActionResult info = info(workInfoVO.getId());
            Map<String, Object> dataMap = JsonUtil.entityToMap(info.getData());
            workInfoVO.setCreatoruserid_name(generaterSwapUtil.userSelectValue(workInfoVO.getCreatoruserid()));

            workInfoVO.setCreatortime_name(workInfoVO.getCreatortime());

            workInfoVO.setSource_name(generaterSwapUtil.getDicName(workInfoVO.getSource(), "532159486043887237"));

            Map<String, Object> assetsinfoidMap = new HashMap<>();
            workInfoVO.setAssetsinfoid_name(generaterSwapUtil.getPopupSelectValue("453260938385031749", "F_Id", "F_Name", workInfoVO.getAssetsinfoid(), assetsinfoidMap, "[]", -1, dataMap));

            workInfoVO.setSelectteam_name(generaterSwapUtil.comSelectValues(workInfoVO.getSelectteam(), false));

            workInfoVO.setEnabledmark_name(generaterSwapUtil.switchSelectValue(workInfoVO.getEnabledmark(), "是", "否"));

            workInfoVO.setQuestion_name(workInfoVO.getQuestion());

            workInfoVO.setField04_name(workInfoVO.getField04());

            workInfoVO.setField03_name(workInfoVO.getField03());

            workInfoVO.setFiles_name(generaterSwapUtil.getFileNameInJson(workInfoVO.getFiles()));

            workInfoVO.setHandleuserid_name(generaterSwapUtil.userSelectValues(workInfoVO.getHandleuserid()));

            workInfoVO.setHandletime_name(workInfoVO.getHandletime() != null ?
                    new Date(workInfoVO.getHandletime()) : null);

            workInfoVO.setHandleresult_name(workInfoVO.getHandleresult());

            workInfoVO.setPrevent_name(workInfoVO.getPrevent());

            workInfoVO.setImages_name(generaterSwapUtil.getFileNameInJson(workInfoVO.getImages()));

            workInfoVO.setConfirmuserid_name(generaterSwapUtil.userSelectValues(workInfoVO.getConfirmuserid()));

            workInfoVO.setConfirmtime_name(workInfoVO.getConfirmtime() != null ?
                    new Date(workInfoVO.getConfirmtime()) : null);
            workInfoVO.setWorkencode_name(workInfoVO.getWorkEncode());


            //根据发现人用户id获取到用户姓名
            workInfoVO.setField02_name(generaterSwapUtil.userSelectValue(workInfoVO.getField02()));
            workInfoVO.setPds_name(workInfoVO.getPds());

            //子表数据转换
        }

        PageListVO vo = new PageListVO();
        vo.setList(listVO);
        PaginationVO page = JsonUtil.getJsonToBean(workInfoPagination, PaginationVO.class);
        vo.setPagination(page);

        if (workInfoPagination.getIsUpdate() == 1) {
            // 更新下载状态
            if (list.size() != 0) {
                workInfoService.updateBatchById(
                        list.stream().peek(item -> item.setIsdownload(1)).collect(Collectors.toList())
                );
            }
        }
        return ActionResult.success(vo);

    }

    /**
     * 创建
     *
     * @param workInfoForm
     * @return
     */
    @PostMapping
    @Transactional
    @ApiOperation("创建")
    public ActionResult create(@RequestBody @Valid WorkInfoForm workInfoForm) throws DataException {
        String b = workInfoService.checkForm(workInfoForm, 0);
        if (StringUtil.isNotEmpty(b)) {
            return ActionResult.fail(b + "不能重复");
        }
        String mainId = RandomUtil.uuId();

        UserInfo userInfo = userProvider.get();
        UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
        workInfoForm.setCreatoruserid(userInfo.getUserId());
        workInfoForm.setCreatortime(DateUtil.getNow());
        WorkInfoEntity entity = JsonUtil.getJsonToBean(workInfoForm, WorkInfoEntity.class);
        entity.setId(mainId);
        //根据工作地点id获取到响应的配电室

        //手动创建 工单编码的生成
        if ("1".equals(entity.getSource())) {
            entity.setWorkEncode(generaterSwapUtil.getBillNumber("rwgd", false));
        }
        //巡检异常 工单编码的生成
        if ("2".equals(entity.getSource())) {
            String code = generaterSwapUtil.getBillNumber("rwgd", false);
            entity.setWorkEncode(code);
            // 巡检——保存工单ID
            CheckTaskAnomalyEntity info = checkTaskAnomalyService.getInfo(workInfoForm.getParentid());
            info.setWorkid(entity.getId());
            info.setWorkcode(code);
            checkTaskAnomalyService.updateById(info);
        }
        //保养异常 工单编码的生成
        if ("3".equals(entity.getSource())) {
            String code = generaterSwapUtil.getBillNumber("rwgd", false);
            entity.setWorkEncode(code);

        }
        workInfoService.save(entity);

        return ActionResult.success("创建成功");
    }


    /**
     * 信息
     *
     * @param id
     * @return
     */
    @ApiOperation("信息")
    @GetMapping("/{id}")
    public ActionResult<WorkInfoInfoVO> info(@PathVariable("id") String id) {
        WorkInfoEntity entity = workInfoService.getInfo(id);
        WorkInfoInfoVO vo = JsonUtil.getJsonToBean(entity, WorkInfoInfoVO.class);
        vo.setCreatoruserid(generaterSwapUtil.userSelectValue(vo.getCreatoruserid()));
        if (vo.getCreatortime() != null) {
            vo.setCreatortime(vo.getCreatortime());
        }

        //子表
        //副表
        return ActionResult.success(vo);
    }

    /**
     * 表单信息(详情页)
     *
     * @param id
     * @return
     */
    @ApiOperation("表单信息(详情页)")
    @GetMapping("/detail/{id}")
    public ActionResult<WorkInfoInfoVO> detailInfo(@PathVariable("id") String id) {
        ActionResult info = info(id);
        Map<String, Object> dataMap = JsonUtil.entityToMap(info.getData());
        WorkInfoEntity entity = workInfoService.getInfo(id);
        WorkInfoInfoVO vo = JsonUtil.getJsonToBean(entity, WorkInfoInfoVO.class);

        //子表数据转换

        //附表数据转换

        //添加到详情表单对象中


        String ymd = DateUtil.daFormatYmd(Long.parseLong(vo.getHappenDate()));
        vo.setHappenDate(ymd);

        vo.setCreatoruserid(generaterSwapUtil.userSelectValue(vo.getCreatoruserid()));

        vo.setCreatortime(vo.getCreatortime());

        vo.setSource(generaterSwapUtil.getDicName(vo.getSource(), "532159486043887237"));

        Map<String, Object> assetsinfoidMap = new HashMap<>();

        vo.setSelectteam(generaterSwapUtil.comSelectValues(vo.getSelectteam(), false));

        vo.setEnabledmark(vo.getEnabledmark());

        vo.setQuestion(vo.getQuestion());

        vo.setFiles(generaterSwapUtil.getFileNameInJson(vo.getFiles()));

        vo.setHandleuseridName(generaterSwapUtil.userSelectValues(vo.getHandleuserid()));

        vo.setHandletime(vo.getHandletime());

        vo.setHandleresult(vo.getHandleresult());

        vo.setPrevent(vo.getPrevent());

        vo.setImages(generaterSwapUtil.getFileNameInJson(vo.getImages()));

        vo.setConfirmuserid(generaterSwapUtil.userSelectValues(vo.getConfirmuserid()));

        vo.setConfirmtime(vo.getConfirmtime());


        return ActionResult.success(vo);
    }


    /**
     * 更新
     *
     * @param id
     * @param workInfoForm
     * @return
     */
    @PutMapping("/{id}")
    @Transactional
    @ApiOperation("更新")
    public ActionResult update(@PathVariable(value = "id") String id, @RequestBody @Valid WorkInfoForm workInfoForm) throws DataException {
        String b = workInfoService.checkForm(workInfoForm, 1);
        if (StringUtil.isNotEmpty(b)) {
            return ActionResult.fail(b + "不能重复");
        }
        UserInfo userInfo = userProvider.get();
        WorkInfoEntity entity = workInfoService.getInfo(id);
        if (entity != null) {
            WorkInfoEntity subentity = JsonUtil.getJsonToBean(workInfoForm, WorkInfoEntity.class);
            subentity.setCreatoruserid(entity.getCreatoruserid());
            subentity.setCreatortime(entity.getCreatortime());
            boolean b1 = workInfoService.updateById(subentity);
            if (!b1) {
                return ActionResult.fail("当前表单原数据已被调整，请重新进入该页面编辑并提交数据");
            }
            return ActionResult.success("更新成功");
        } else {
            return ActionResult.fail("更新失败，数据不存在");
        }
    }

    /**
     * 导出Excel
     *
     * @return
     */
    @ApiOperation("导出Excel")
    @PostMapping("/Actions/Export")
    public ActionResult Export(@RequestBody WorkInfoPagination workInfoPagination) throws IOException {
        if (StringUtil.isEmpty(workInfoPagination.getSelectKey())) {
            return ActionResult.fail("请选择导出字段");
        }
        List<WorkInfoEntity> list = workInfoService.getTypeList(workInfoPagination, workInfoPagination.getDataType());
        //处理id字段转名称，若无需转或者为空可删除

        List<WorkInfoListVO> listVO = JsonUtil.getJsonToList(list, WorkInfoListVO.class);
        for (WorkInfoListVO workInfoVO : listVO) {
            ActionResult info = info(workInfoVO.getId());
            Map<String, Object> dataMap = JsonUtil.entityToMap(info.getData());
            workInfoVO.setCreatoruserid_name(generaterSwapUtil.userSelectValue(workInfoVO.getCreatoruserid()));

            workInfoVO.setCreatortime_name(workInfoVO.getCreatortime());

            workInfoVO.setSource_name(generaterSwapUtil.getDicName(workInfoVO.getSource(), "532159486043887237"));

            Map<String, Object> assetsinfoidMap = new HashMap<>();
            workInfoVO.setAssetsinfoid_name(generaterSwapUtil.getPopupSelectValue("453260938385031749", "F_Id", "F_Name", workInfoVO.getAssetsinfoid(), assetsinfoidMap, "[]", -1, dataMap));

            workInfoVO.setSelectteam_name(generaterSwapUtil.comSelectValues(workInfoVO.getSelectteam(), false));

            workInfoVO.setEnabledmark_name(generaterSwapUtil.switchSelectValue(workInfoVO.getEnabledmark(), "是", "否"));

            workInfoVO.setQuestion_name(workInfoVO.getQuestion());

            workInfoVO.setFiles_name(generaterSwapUtil.getFileNameInJson(workInfoVO.getFiles()));

            workInfoVO.setHandleuserid_name(generaterSwapUtil.userSelectValues(workInfoVO.getHandleuserid()));

            workInfoVO.setHandletime_name(workInfoVO.getHandletime() != null ?
                    new Date(workInfoVO.getHandletime()) : null);

            workInfoVO.setHandleresult_name(workInfoVO.getHandleresult());

            workInfoVO.setPrevent_name(workInfoVO.getPrevent());

            workInfoVO.setImages_name(generaterSwapUtil.getFileNameInJson(workInfoVO.getImages()));

            workInfoVO.setConfirmuserid_name(generaterSwapUtil.userSelectValues(workInfoVO.getConfirmuserid()));

            workInfoVO.setConfirmtime_name(workInfoVO.getConfirmtime() != null ?
                    new Date(workInfoVO.getConfirmtime()) : null);

            workInfoVO.setWorkencode_name(workInfoVO.getWorkEncode());

            // 对日期格式转换
            SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
            String time = workInfoVO.getHappenDate() != null ? s.format(workInfoVO.getHappenDate()) : "";
            workInfoVO.setHappendate_name(time);

            System.out.println(workInfoVO.getHappendate_name());
            workInfoVO.setField02_name(generaterSwapUtil.userSelectValues(workInfoVO.getField02()));

            workInfoVO.setPds_name(workInfoVO.getPds());

            workInfoVO.setField04_name(workInfoVO.getField04());

            workInfoVO.setField03_name(workInfoVO.getField03());

            //子表数据转换
        }

        //转换为map输出
        List<Map<String, Object>> mapList = JsonUtil.getJsonToListMap(JsonUtil.getObjectToStringDateFormat(listVO, "yyyy-MM-dd HH:mm:ss"));
        mapList.stream().forEach(map -> {
            Map<String, Object> map2 = new HashMap<>();
            map.putAll(map2);
        });
        String[] keys = !StringUtil.isEmpty(workInfoPagination.getSelectKey()) ? workInfoPagination.getSelectKey().split(",") : new String[0];
        UserInfo userInfo = userProvider.get();
        DownloadVO vo = this.creatModelExcel(configValueUtil.getTemporaryFilePath(), mapList, keys, userInfo);
        return ActionResult.success(vo);
    }

    //导出表格
    public DownloadVO creatModelExcel(String path, List<Map<String, Object>> list, String[] keys, UserInfo userInfo) {
        DownloadVO vo = DownloadVO.builder().build();
        List<ExcelExportEntity> entitys = new ArrayList<>();
        if (keys.length > 0) {
            for (String key : keys) {
                switch (key) {
                    case "creatoruserid":
                        entitys.add(new ExcelExportEntity("创建用户", "creatoruserid_name"));
                        break;
                    case "creatortime":
                        entitys.add(new ExcelExportEntity("创建时间", "creatortime_name"));
                        break;
                    case "source":
                        entitys.add(new ExcelExportEntity("来源", "source_name"));
                        break;
                    case "assetsinfoid":
                        entitys.add(new ExcelExportEntity("工作地点", "assetsinfoid_name"));
                        break;
                    case "selectteam":
                        entitys.add(new ExcelExportEntity("责任队", "selectteam_name"));
                        break;
                    case "enabledmark":
                        entitys.add(new ExcelExportEntity("是否生成", "enabledmark_name"));
                        break;
                    case "question":
                        entitys.add(new ExcelExportEntity("事件描述", "question_name"));
                        break;
                    case "files":
                        entitys.add(new ExcelExportEntity("指导文件", "files_name"));
                        break;
                    case "handleuserid":
                        entitys.add(new ExcelExportEntity("处理人", "handleuserid_name"));
                        break;
                    case "handletime":
                        entitys.add(new ExcelExportEntity("处理时间", "handletime_name"));
                        break;
                    case "handleresult":
                        entitys.add(new ExcelExportEntity("处理结果", "handleresult_name"));
                        break;
                    case "prevent":
                        entitys.add(new ExcelExportEntity("再发处理措施", "prevent_name"));
                        break;
                    case "images":
                        entitys.add(new ExcelExportEntity("图片", "images_name"));
                        break;
                    case "confirmuserid":
                        entitys.add(new ExcelExportEntity("确认人", "confirmuserid_name"));
                        break;
                    case "confirmtime":
                        entitys.add(new ExcelExportEntity("确认时间", "confirmtime_name"));
                        break;
                    case "workencode":
                        entitys.add(new ExcelExportEntity("工单编码", "workencode_name"));
                        break;
                    case "happendate":
                        entitys.add(new ExcelExportEntity("发生日期", "happendate_name"));
                        break;
                    case "field02":
                        entitys.add(new ExcelExportEntity("发现人", "field02_name"));
                        break;
                    case "pds":
                        entitys.add(new ExcelExportEntity("配电室", "pds_name"));
                        break;
                    case "field04":
                        entitys.add(new ExcelExportEntity("故障真因", "field04_name"));
                        break;
                    case "field03":
                        entitys.add(new ExcelExportEntity("处理内容", "field03_name"));
                        break;
                    default:
                        break;

                }
            }
            List<String> keylist = new ArrayList<>();
            for (String key : keys) {
                keylist.add(key);
            }
        }

        ExportParams exportParams = new ExportParams(null, "表单信息");
        exportParams.setType(ExcelType.XSSF);
        try {
            @Cleanup Workbook workbook = new HSSFWorkbook();
            if (entitys.size() > 0) {
                if (list.size() == 0) {
                    list.add(new HashMap<>());
                }
                workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
            }
            String fileName = "WorkData" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".xls";
            MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
            String temporaryFilePath = configValueUtil.getTemporaryFilePath();
            FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
            vo.setName(fileInfo.getFilename());
            vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
        } catch (Exception e) {
            log.error("信息导出Excel错误:{}", e.getMessage());
            e.printStackTrace();
        }
        return vo;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    @Transactional
    public ActionResult delete(@PathVariable("id") String id) {
        WorkInfoEntity entity = workInfoService.getInfo(id);
        if (entity != null) {
            workInfoService.delete(entity);
        }
        return ActionResult.success("删除成功");
    }


    @Autowired
    private CheckPlanItemService checkPlanItemService;






}
